import jieba

excludes = {"将军", "却说", "荆州", "二人", "不可", "不能", "如此"}

txt = open("threekingdoms.txt", "r", encoding="utf-8").read()
words = jieba.lcut(txt)
counts = {}
for word in words:
    if len(word) < 2 or word in excludes:
        continue
    else:
        counts[word] = counts.get(word, 0) + 1
items = list(counts.items())
items.sort(key=lambda x: x[1], reverse=True)
for i in range(len(items)):
    print(i, items[i])
